package com.eascs.admin.o2o.operation.operations;

import org.springframework.stereotype.Component;

import com.alibaba.dubbo.config.annotation.Reference;
import com.eascs.app.context.ConfigContext;
import com.eascs.site.view.button.Button;
import com.eascs.site.view.button.ButtonHelper;
import com.eascs.web.sso.User;
import com.eascs.web.sso.UserHolder;
import com.eascs.workflow.common.entity.sys.HREmployeeAuditor;
import com.eascs.workflow.common.service.sys.EmployeeService;

@Component
public class InvalidOperation extends ApplyOperation {
//	@Reference
//	EmployeeService employeeService;
	@Override
	public String getOperation() {
		return "invalid";
	}

	@Override
	public String getTitle() {
		return "作废";
	}

	@Override
	public String getMenuCode() {
		return "invalid";
	}

	@Override
	public String getSql() {
		User user = UserHolder.getUser();
		
//		String operator_no="'"+user.getNo()+"'";
		String sql = super.getSql();
		sql = ConfigContext.getStringValue(sql, sql);
		sql += " and l.wf_type not in ('O','T','HN','DC','YQ') and l.loan_flg='N'";
		if (!user.isSuperAdministrator()) {
//			HREmployeeAuditor auditor=employeeService.getAuditorWithNoAndType(user.getNo(), "BO");
//			System.out.println("auditor="+auditor);
////			System.out.println("auditor1="+auditor.getAuditorName());
//			if (auditor!=null) {
//				if (auditor.getAuditorNo()!=null) {
//					operator_no+=",'"+auditor.getEmployeeNo()+"'";
//				}
//			}
//			sql+=" and l.operator_no in ("+operator_no+")";
			sql+=" and l.operator_no='"+user.getNo()+"' ";
		}
//		System.out.println("sql="+sql);
		return sql;
	}

	@Override
	public Button[] getOperationButtons() {		
		return new Button[] { ButtonHelper.createAjaxButton("作废", "/rbadloan/cacle?tType=NEWCANCLE&loanapplyNo=") };
	}
	@Override
	public Button[] getTitleButtons() {				
		return new Button[] {null,null,null,null,null,null,null, ButtonHelper.createAjaxButton(null, "/cacler/detail?id={9}") };
	}
}
